package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaFankui;
import com.ruoyi.system.service.IJiajiaFankuiService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 意见反馈Controller
 * 
 * @author ruoyi
 * @date 2021-10-13
 */
@Controller
@RequestMapping("/jiajia/fankui")
public class JiajiaFankuiController extends BaseController
{
    private String prefix = "jiajia/fankui";

    @Autowired
    private IJiajiaFankuiService jiajiaFankuiService;

    @RequiresPermissions("jiajia:fankui:view")
    @GetMapping()
    public String fankui()
    {
        return prefix + "/fankui";
    }

    /**
     * 查询意见反馈列表
     */
    @RequiresPermissions("jiajia:fankui:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaFankui jiajiaFankui) {
        startPage();
        List<JiajiaFankui> list = jiajiaFankuiService.selectJiajiaFankuiList(jiajiaFankui);

        return getDataTable(list);
    }

    /**
     * 导出意见反馈列表
     */
    @RequiresPermissions("jiajia:fankui:export")
    @Log(title = "意见反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaFankui jiajiaFankui)
    {
        List<JiajiaFankui> list = jiajiaFankuiService.selectJiajiaFankuiList(jiajiaFankui);
        ExcelUtil<JiajiaFankui> util = new ExcelUtil<JiajiaFankui>(JiajiaFankui.class);
        return util.exportExcel(list, "意见反馈数据");
    }

    /**
     * 新增意见反馈
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存意见反馈
     */
    @RequiresPermissions("jiajia:fankui:add")
    @Log(title = "意见反馈", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaFankui jiajiaFankui)
    {
        return toAjax(jiajiaFankuiService.insertJiajiaFankui(jiajiaFankui));
    }

    /**
     * 修改意见反馈
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaFankui jiajiaFankui = jiajiaFankuiService.selectJiajiaFankuiById(id);
        mmap.put("jiajiaFankui", jiajiaFankui);
        return prefix + "/edit";
    }

    /**
     * 修改保存意见反馈
     */
    @RequiresPermissions("jiajia:fankui:edit")
    @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaFankui jiajiaFankui)
    {
        return toAjax(jiajiaFankuiService.updateJiajiaFankui(jiajiaFankui));
    }

    /**
     * 删除意见反馈
     */
    @RequiresPermissions("jiajia:fankui:remove")
    @Log(title = "意见反馈", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaFankuiService.deleteJiajiaFankuiByIds(ids));
    }
}
